<?php
namespace Admin\Controller;
use Think\Controller;
class OrderController extends Controller {
	public function __construct(){
		parent::__construct();
		if(!$_SESSION['admin_is_login']){
			$this->redirect('admin/Auth/login');
		}
	}
    public function index(){
    	$orders_model = M('orders');
		$count=$orders_model->count();
		$Page=new \Org\Util\Page($count,5);
		$show=$Page->show();
		$orders = $orders_model->field("*")->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign('orders',$orders);
		$this->assign('page',$show);
		$this->display();
    }
    public function view($id){
    	$order=M('orders')->where('id='.$id)->find();
    	$product=M('order_products')->where('order_id='.$id)->join('product_catalog ON order_products.product_catalog_id=product_catalog.id')->select();
    	$this->assign('order',$order);
    	$this->assign('product',$product);
    	$this->display();
    }
}